package cn.wolfcode.web.controller;

import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.Product;
import cn.wolfcode.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by lanxw
 */
@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {
    @Autowired
    private IProductService productService;

    @GetMapping("/queryProductByIds")
    public Result<List<Product>> queryProductByIds(@RequestParam("ids") List<Long> ids) {
        List<Product> products = productService.queryProductByIds(ids);
        return Result.success(products);
    }

    /**
     * 根据商品id查询商品信息
     *
     * @param productId
     * @return
     */
    @GetMapping("/findById")
    public Result<Product> findById(Long productId) {
        Product product = productService.findById(productId);
        return Result.success(product);
    }
}
